<?php

namespace App\Http\Controllers\Library;

use Illuminate\Http\Request;
use LibraryService;

use App\Http\Controllers\Controller;

class HomeController extends Controller
{

    public function index()
    {
        return view('app.library.index');
    }

    public function search(Request $request)
    {
        $keyword = $request->get('keyword');

        $page = $request->get('page') ? : 1;

        return LibraryService::search($keyword, $page);
    }

    public function location(Request $request)
    {
        $ctrlRd = $request->get('ctrlRd');

        $ctrlNo = $request->get('ctrlNo');

        $result = LibraryService::getLocation($ctrlRd, $ctrlNo);

        if($result === false){
            return ['status' => 'fail', 'msg' => '该书籍异常，无法查询'];
        }

        return $result;
    }

}
